# coding=utf-8
from ToolsConfig import *


def InvisiblePlayerModel(playerId):
    """
    隐藏玩家模型
    """
    comp = clientCompFactory.CreateActorRender(playerId)
    comp.RemovePlayerRenderController('controller.render.player.first_person')
    comp.RemovePlayerRenderController('controller.render.player.third_person')
    comp.RemovePlayerRenderController('controller.render.player.map')
    comp.RebuildPlayerRender()


def RestorePlayerModel(playerId):
    """
    显示玩家模型
    """
    comp = clientCompFactory.CreateActorRender(playerId)
    comp.AddPlayerRenderController('controller.render.player.first_person', 'variable.is_first_person')
    comp.AddPlayerRenderController(
        'controller.render.player.third_person', '!variable.is_first_person && !variable.map_face_icon'
    )
    comp.AddPlayerRenderController('controller.render.player.map', 'variable.map_face_icon')
    comp.RebuildPlayerRender()


class PlayerVanillaAnimation(object):
    Attack = 'first_person_attack_controller'
    MoveArms = 'move.arms'
    MoveLegs = 'move.legs'
    Holding = 'holding'
    EmptyHand = 'first_person_empty_hand'


__d = {
    PlayerVanillaAnimation.Attack: 'controller.animation.player.first_person_attack',
    PlayerVanillaAnimation.MoveArms: 'animation.player.move.arms',
    PlayerVanillaAnimation.MoveLegs: 'animation.player.move.legs',
    PlayerVanillaAnimation.Holding: 'animation.player.holding',
    PlayerVanillaAnimation.EmptyHand: 'animation.player.first_person.empty_hand'
}


def InvisibleVanillaAnimation(playerId, *args):
    """
    屏蔽原版动画
    """
    comp = clientCompFactory.CreateActorRender(playerId)
    for _ in args:
        comp.AddPlayerAnimation(_, 'animation.unvanilla.all') if __d[_].startswith(
            'animation') else comp.AddPlayerAnimationController(_, 'controller.animation.unvanilla.all')
    return comp


def RestoreVanillaAnimation(playerId, *args):
    """
    还原原版动画
    """
    comp = clientCompFactory.CreateActorRender(playerId)
    for _ in args:
        comp.AddPlayerAnimation(_, __d[_]) if __d[_].startswith(
            'animation') else comp.AddPlayerAnimationController(_, __d[_])
    return comp
